#pragma once

class CFLVHelper
{
public:
	CFLVHelper(){}
	virtual ~CFLVHelper(){}

public:
	static uint8_t to_int8(uint8_t*& ptr)
	{
		uint8_t v = *ptr;
		ptr ++;
		return v;
	}
	static uint16_t to_int16(uint8_t*& ptr)
	{
		uint16_t v = *((uint16_t*)ptr);
		v = ntohs(v);
		ptr += 2;
		return v;
	}
	static uint32_t to_int24(uint8_t*& ptr)
	{
		uint32_t v = *((uint32_t*)ptr);
		v = v << 8;
		v = ntohl(v);
		ptr += 3;
		return v;
	}
	static uint32_t to_int32(uint8_t*& ptr)
	{
		uint32_t v = *((uint32_t*)ptr);
		v = ntohl(v);
		ptr += 4;
		return v;
	}


	//code copy from FLVExtractCL project
	//
	static int bit_Read(uint64_t & x, int length)
    {
		int r = (int)(x >> (64 - length));
		x <<= length;
		return r;
	}

	//code copy from FLVExtractCL project
	//
	static void Write(uint64_t & x, int length, int value)
    {
		uint64_t mask = 0xFFFFFFFFFFFFFFFF >> (64 - length);
		x = (x << length) | ((uint64_t)value & mask);
	}

};







